#ifndef COORDTOPOCENTRIC_H
#define COORDTOPOCENTRIC_H

#include "util.h"

#include <string>
#include <sstream>
#include <iomanip>

namespace libsgp4
{

/**
 * @brief Stores a topocentric location (azimuth, elevation, range and range
 * rate).
 *
 * Azimuth and elevation are stored in radians. Range in kilometres. Range
 * rate in kilometres/second.
 * 存储一个以观察者为中心的位置（方位角、仰角、距离和距离变化率）。
 * 方位角和仰角以弧度为单位存储。距离以千米为单位。距离变化率以千米/秒为单位。
 */
struct CoordTopocentric
{
public:
    /**
     * Default constructor
     * 默认构造函数
     */
    CoordTopocentric() = default;

    /**
     * Constructor
     * @param[in] az azimuth in radians
     * @param[in] el elevation in radians
     * @param[in] rnge range in kilometers
     * @param[in] rnge_rate range rate in kilometers per second
     * 方位角和仰角以弧度为单位存储。距离以千米为单位。距离变化率以千米/秒为单位。
     */
    CoordTopocentric(
        double az,
        double el,
        double rnge,
        double rnge_rate)
        : azimuth(az)
        , elevation(el)
        , range(rnge)
        , range_rate(rnge_rate)
    {
    }

    /**
     * Copy constructor
     * @param[in] topo object to copy from
     */
    CoordTopocentric(const CoordTopocentric& topo)
    {
        azimuth = topo.azimuth;
        elevation = topo.elevation;
        range = topo.range;
        range_rate = topo.range_rate;
    }

    /**
     * Assignment operator
     * @param[in] topo object to copy from
     */
    CoordTopocentric& operator=(const CoordTopocentric& topo)
    {
        if (this != &topo)
        {
            azimuth = topo.azimuth;
            elevation = topo.elevation;
            range = topo.range;
            range_rate = topo.range_rate;
        }
        return *this;
    }

    /**
     * Dump this object to a string
     * 转为字符串
     * @returns string
     */
    std::string ToString() const
    {
        std::stringstream ss;
        ss << std::right << std::fixed << std::setprecision(3);
        ss << "Az: " << std::setw(8) << Util::RadiansToDegrees(azimuth);
        ss << ", El: " << std::setw(8) << Util::RadiansToDegrees(elevation);
        ss << ", Rng: " << std::setw(10) << range;
        ss << ", Rng Rt: " << std::setw(7) << range_rate;
        return ss.str();
    }

    /** azimuth in radians */
    double azimuth{};
    /** elevations in radians */
    double elevation{};
    /** range in kilometers */
    double range{};
    /** range rate in kilometers per second */
    double range_rate{};
};


inline std::ostream& operator<<(std::ostream& strm, const CoordTopocentric& t)
{
    return strm << t.ToString();
}//使得 CoordTopocentric 类的对象能够与其他标准库类型（如整数、浮点数和字符串）一起无缝地使用在输出流中。

} // namespace libsgp4

#endif // COORDTOPOCENTRIC_H
